package pers.fjl.common.po;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.Version;
import com.baomidou.mybatisplus.annotations.TableField;
import com.baomidou.mybatisplus.annotations.TableName;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import pers.fjl.common.validation.ValidGroup;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.io.Serializable;
import java.math.BigInteger;
import java.time.LocalDateTime;

/**
 * <p>
 * 用户表
 * </p>
 *
 * @author fangjiale
 * @since 2020-12-14
 */
@ApiModel(value = "表[user]的实体类")
@Data
@TableName(value = "user")
public class User extends Model<User> implements Serializable {
    private static final long serialVersionUID = 2193906121712125255L;

    /**
     * 用户编号
     */
    @ApiModelProperty(value = "自增id")
    @TableField("`id`")
    @TableId(value = "id")
    private String id;

    /**
     * 用户名
     */
    @ApiModelProperty(value = "用户名", dataType = "String")
    @TableField("`username`")
    @NotBlank(message = "用户名不能为空", groups = {ValidGroup.GroupA.class, ValidGroup.GroupB.class})
    @NotNull(message = "用户名不能为空", groups = {ValidGroup.GroupA.class, ValidGroup.GroupB.class})
    @Size(min = 3, max = 10, message = "用户名长度应在3到10个字符内", groups = {ValidGroup.GroupA.class, ValidGroup.GroupB.class})
    private String username;

    /**
     * 密码,用户使用
     */
    @ApiModelProperty(value = "密码", dataType = "String")
    @TableField("`password`")
    @NotBlank(message = "密码不能为空", groups = {ValidGroup.GroupA.class})
    @NotNull(message = "密码不能为空", groups = {ValidGroup.GroupA.class})
    @Size(min = 3, max = 15, message = "密码长度应在3到15个字符内", groups = {ValidGroup.GroupA.class})
    private String password;

    /**
     * 手机号
     */
    @ApiModelProperty(value = "手机号", dataType = "String")
    @TableField("`mobile`")
    private String mobile;

    /**
     * 真实姓名
     */
    @ApiModelProperty(value = "真实姓名", dataType = "String")
    @TableField("`real_name`")
    @NotBlank(message = "用户名不能为空", groups = {ValidGroup.GroupA.class, ValidGroup.GroupB.class})
    @NotNull(message = "用户名不能为空", groups = {ValidGroup.GroupA.class, ValidGroup.GroupB.class})
    @Size(min = 1, max = 15, message = "真实姓名长度应在1到15个字符内", groups = {ValidGroup.GroupA.class, ValidGroup.GroupB.class})
    private String realName;

    /**
     * 创建时间
     */
    @ApiModelProperty(value = "创建时间")
    @TableField("`create_time`")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm", timezone = "GMT+8")
    private LocalDateTime createTime;

    /**
     * 累计消费金额
     */
    @ApiModelProperty(value = "累计消费金额", dataType = "Integer")
    @TableField("`accumulated_consumption_ammount`")
    private Integer accumulatedConsumptionAmmount;

    /**
     * 通用状态,2正常,3删除
     */
    @ApiModelProperty(value = "通用状态,2正常,3删除", dataType = "boolean")
    @TableField("`data_status`")
    private boolean dataStatus;

    /**
     * 最后登录ip
     */
    @ApiModelProperty(value = "最后登录ip", dataType = "String")
    @TableField("`last_ip`")
    private String lastIp;

    /**
     * 乐观锁
     */
    @ApiModelProperty(value = "乐观锁", dataType = "Integer")
    @TableField("`version`")
    @Version
    private Integer version;

    @ApiModelProperty(value = "角色号", dataType = "Integer")
    @TableField("`rid`")
    private Integer rid;
}
